<template>
	<view>
	<view v-if="noticeType === 'trajectory'">
		<uni-card :title="goOutItem.studentName" :extra="goOutItem.className">
			<view>
				<image style="width: 100%;" :src="goOutItem.snapFtpUrl" @click="imgClick(goOutItem.snapFtpUrl)"></image>
			</view>
			<view>  
				<text>时间：{{ goOutItem.faceTime }}</text>  
			</view>  
			<view>
				<text>类型：{{ getType(goOutItem.type) }}</text>  
			</view>
		</uni-card>
	</view>
	<view v-if="noticeType === 'dormitory'">
		<uni-card :title="attendanceItem.studentName" :extra="attendanceItem.className">
			<view v-if="attendanceItem.mendCardPhoto != null && attendanceItem.mendCardPhoto != ''">
				<image style="width: 100%;" :src="attendanceItem.mendCardPhoto" @click="imgClick(attendanceItem.mendCardPhoto)"></image>
			</view>
			<view>  
				<text>考勤时间：{{ attendanceItem.accessDate }}</text>  
			</view>  
			<view>
				<text>考勤状态：{{ getDormitoryType(attendanceItem.attenceStatus) }}</text>  
			</view>
		</uni-card>
	</view>
	</view>
</template>

<script>
	import parent from '@/api/modules/parent'
	export default {
		data() {
			return {
				goOutItem: {},
				attendanceItem: {},
				studentId: '',
				faceTime: '',
				noticeType: ''
			}
		},
		onLoad(options) {
			this.studentId = options.studentId;
			this.faceTime = options.faceTime;
			this.noticeType = options.type;
			if(this.noticeType === 'dormitory') {
				this.loadDormitoryData()
			} 
			if(this.noticeType === 'trajectory') {
				this.loadData()
			}
		},
		methods: {
			//照片预览
			imgClick(url) {
				uni.previewImage({
					current: 0,
					urls: [url]
				})
			},
			loadDormitoryData() {
				parent.getStudentDorAttendance(this.studentId, this.faceTime).then(resp => {
					this.attendanceItem = resp.data
				})
			},
			loadData() {
				parent.getChildGoOutDetail(this.studentId, this.faceTime).then(resp => {
					this.goOutItem = resp.data
				})
			},
			getType(type) {
				if(type === '1') {
					return '进入校园'
				}else if(type === '2') {
					return '离开校园'
				}else if(type === '3') {
					return '宿舍打卡'
				}else {
					return ''
				}
			},
			getDormitoryType(type) {
				if(type === '1') {
					return '正常'
				}else if(type === '2') {
					return '未归寝'
				}else if(type === '3') {
					return '晚归'
				}else if(type === '4') {
					return '请假'
				}else {
					return ''
				}
			}
			
		}
	}
</script>

<style>

</style>
